<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    
    <title>添加用户信息</title>
	<script type="text/javascript">
  		function check(){
  			 var username = document.addUserForm.username.value;
  			 var password = document.addUserForm.password.value;
  			 var mail = document.addUserForm.mail.value;
  			var password_reg=/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{6,10}$/;//  验证密码格式的正则表达式
  			 var mail_reg =/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;//  验证邮箱格式的正则表达式
  			 if(username=="" || password=="" ){
  			 	alert("用户名或密码不能为空");
  			 }else if(password_reg.test(password)==false){
  			 	alert("密码长度6-10位，由数字（0-9）、大写字母（A-Z）、小写字母（a-z）共同组成，缺一不可！");
  			 }else if(mail!="" && mail_reg.test(mail)==false ){
  			 	alert("邮箱格式错误");
  			 }else{
  			 	document.addUserForm.submit();
  			 }
  			
  		}
  	</script>
  	<style type="text/css">
		div{
			margin-top: 15%;
			margin-bottom: 15%;
		}
	</style>
  </head>
  
  <body>
  		<div align="center">
  		<h2>添加用户信息</h2>
    	<form name="addUserForm" action="servlet/AddUserServlet" method="post">
    		用户名：<input type="text" name="username"><br><br>
    		密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="text" name="password"><br><br>
    		性&nbsp;&nbsp;&nbsp;&nbsp;别：<input type="text" name="usex"><br><br>
    		邮&nbsp;&nbsp;&nbsp;&nbsp;箱：<input type="text" name="mail"><br><br>
    		<input type="button" value="提交" onclick="check()">
    	</form>
    	</div>
  </body>
</html>
